﻿using AdminFrame.Domain.Parameters;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace AdminFrame.EntityFrameworkCore.EntityConfigurations
{
    public class ParameterConfiguration : IEntityTypeConfiguration<Parameter>
    {
        public void Configure(EntityTypeBuilder<Parameter> builder)
        {
            builder.ToTable("app_Parameters");
            builder.ConfigureByConvention();

            builder.Property(x => x.Name)
                .IsRequired()
                .HasMaxLength(128);

            builder.Property(x => x.Code)
                .IsRequired()
                .HasMaxLength(64);

            builder.Property(x => x.Type)
                .IsRequired()
                .HasMaxLength(32);

            builder.Property(x => x.Description)
                .HasMaxLength(512);

            builder.HasIndex(x => x.Code).IsUnique();
        }
    }
}